package org.zhs.springframework;

import org.junit.jupiter.api.Test;
import org.zhs.springframework.bean.UserService;
import org.zhs.springframework.factory.config.BeanDefinition;
import org.zhs.springframework.factory.support.DefaultListableBeanFactory;

public class test_BeanFactory {

    @Test
    public void test_BeanFactory(){
        //1.初始化BeanFactory接口
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        //2.注册 Bean对象
        BeanDefinition beanDefinition = new BeanDefinition(UserService.class);
        beanFactory.registerBeanDefinition("userService", beanDefinition);

        //3.获取 Bean对象
        UserService userService = (UserService) beanFactory.getBean("userService", "测试用户");
        userService.queryUserInfo();
    }

}
